#!/bin/sh

SHELL=${SHELL:-/bin/sh}
ac_aux_dir=scripts

# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
  { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
   { (exit 1); exit 1; }; }

  ac_build_alias=$build_alias
  test "x$ac_build_alias" = x &&
  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
  test "x$ac_build_alias" = x &&
  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
          echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
      { (exit 1); exit 1; }; }
  ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
  { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
          echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
      { (exit 1); exit 1; }; }


case $ac_cv_build in
*-*-*) ;;
*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
echo "$as_me: error: invalid value of canonical build" >&2;}
   { (exit 1); exit 1; }; };;
esac
build=$ac_cv_build
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_build
shift
build_cpu=$1
build_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
build_os=$*
IFS=$ac_save_IFS
case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac

case $host_os in
  *cygwin* ) CYGWIN=yes;;
         * ) CYGWIN=no;;
esac

if test $HAVE_UNAME=yes -a x`uname -s` = xSunOS
then


if $TRUEPRG; then
  HAVE_SUN_OS_TRUE=
  HAVE_SUN_OS_FALSE='#'
else
  HAVE_SUN_OS_TRUE='#'
  HAVE_SUN_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_SUN_OS_TRUE=
  HAVE_SUN_OS_FALSE='#'
else
  HAVE_SUN_OS_TRUE='#'
  HAVE_SUN_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xOSF1
then


if $TRUEPRG; then
  HAVE_OSF1_OS_TRUE=
  HAVE_OSF1_OS_FALSE='#'
else
  HAVE_OSF1_OS_TRUE='#'
  HAVE_OSF1_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_OSF1_OS_TRUE=
  HAVE_OSF1_OS_FALSE='#'
else
  HAVE_OSF1_OS_TRUE='#'
  HAVE_OSF1_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xAIX
then


if $TRUEPRG; then
  HAVE_AIX_OS_TRUE=
  HAVE_AIX_OS_FALSE='#'
else
  HAVE_AIX_OS_TRUE='#'
  HAVE_AIX_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_AIX_OS_TRUE=
  HAVE_AIX_OS_FALSE='#'
else
  HAVE_AIX_OS_TRUE='#'
  HAVE_AIX_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xHP-UX
then


if $TRUEPRG; then
  HAVE_HPUX_OS_TRUE=
  HAVE_HPUX_OS_FALSE='#'
else
  HAVE_HPUX_OS_TRUE='#'
  HAVE_HPUX_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_HPUX_OS_TRUE=
  HAVE_HPUX_OS_FALSE='#'
else
  HAVE_HPUX_OS_TRUE='#'
  HAVE_HPUX_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xLinux
then


if $TRUEPRG; then
  HAVE_LINUX_OS_TRUE=
  HAVE_LINUX_OS_FALSE='#'
else
  HAVE_LINUX_OS_TRUE='#'
  HAVE_LINUX_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_LINUX_OS_TRUE=
  HAVE_LINUX_OS_FALSE='#'
else
  HAVE_LINUX_OS_TRUE='#'
  HAVE_LINUX_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xFreeBSD
then


if $TRUEPRG; then
  HAVE_FREEBSD_OS_TRUE=
  HAVE_FREEBSD_OS_FALSE='#'
else
  HAVE_FREEBSD_OS_TRUE='#'
  HAVE_FREEBSD_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_FREEBSD_OS_TRUE=
  HAVE_FREEBSD_OS_FALSE='#'
else
  HAVE_FREEBSD_OS_TRUE='#'
  HAVE_FREEBSD_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xNetBSD
then


if $TRUEPRG; then
  HAVE_NETBSD_OS_TRUE=
  HAVE_NETBSD_OS_FALSE='#'
else
  HAVE_NETBSD_OS_TRUE='#'
  HAVE_NETBSD_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_NETBSD_OS_TRUE=
  HAVE_NETBSD_OS_FALSE='#'
else
  HAVE_NETBSD_OS_TRUE='#'
  HAVE_NETBSD_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xOpenBSD
then


if $TRUEPRG; then
  HAVE_OPENBSD_OS_TRUE=
  HAVE_OPENBSD_OS_FALSE='#'
else
  HAVE_OPENBSD_OS_TRUE='#'
  HAVE_OPENBSD_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_OPENBSD_OS_TRUE=
  HAVE_OPENBSD_OS_FALSE='#'
else
  HAVE_OPENBSD_OS_TRUE='#'
  HAVE_OPENBSD_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xBSD/OS
then


if $TRUEPRG; then
  HAVE_BSDI_OS_TRUE=
  HAVE_BSDI_OS_FALSE='#'
else
  HAVE_BSDI_OS_TRUE='#'
  HAVE_BSDI_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_BSDI_OS_TRUE=
  HAVE_BSDI_OS_FALSE='#'
else
  HAVE_BSDI_OS_TRUE='#'
  HAVE_BSDI_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xSGI
then


if $TRUEPRG; then
  HAVE_SGI_OS_TRUE=
  HAVE_SGI_OS_FALSE='#'
else
  HAVE_SGI_OS_TRUE='#'
  HAVE_SGI_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_SGI_OS_TRUE=
  HAVE_SGI_OS_FALSE='#'
else
  HAVE_SGI_OS_TRUE='#'
  HAVE_SGI_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xIRIX -o x`uname -s` = xIRIX64
then



if $TRUEPRG; then
  HAVE_IRIX_OS_TRUE=
  HAVE_IRIX_OS_FALSE='#'
else
  HAVE_IRIX_OS_TRUE='#'
  HAVE_IRIX_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_IRIX_OS_TRUE=
  HAVE_IRIX_OS_FALSE='#'
else
  HAVE_IRIX_OS_TRUE='#'
  HAVE_IRIX_OS_FALSE=
fi
fi

if test $HAVE_UNAME=yes -a x`uname -s` = xDarwin
then


if $TRUEPRG; then
  HAVE_DARWIN_OS_TRUE=
  HAVE_DARWIN_OS_FALSE='#'
else
  HAVE_DARWIN_OS_TRUE='#'
  HAVE_DARWIN_OS_FALSE=
fi

else


if $FALSEPRG; then
  HAVE_DARWIN_OS_TRUE=
  HAVE_DARWIN_OS_FALSE='#'
else
  HAVE_DARWIN_OS_TRUE='#'
  HAVE_DARWIN_OS_FALSE=
fi
fi


# -----------------------------------------------------------
# ----------------------------------------------------------
if test "x$DISTNAME" != "x"
then
        echo "distname set to $DISTNAME"
elif test $HAVE_UNAME=yes -a x`uname -s` = xOSF1
then
        DISTNAME=alpha
elif test $HAVE_UNAME=yes -a x`uname -s` = xAIX
then
        DISTNAME=aix
elif test $HAVE_UNAME=yes -a x`uname -s` = xHP-UX
then
        DISTNAME=hpux
elif test $HAVE_UNAME=yes -a x`uname -s` = xSunOS
then
        DISTNAME=solaris
elif test $HAVE_UNAME=yes -a x`uname -s` = xFreeBSD
then
        DISTNAME=freebsd
elif test $HAVE_UNAME=yes -a x`uname -s` = xNetBSD
then
        DISTNAME=netbsd
elif test $HAVE_UNAME=yes -a x`uname -s` = xOpenBSD
then
        DISTNAME=openbsd
elif test $HAVE_UNAME=yes -a x`uname -s` = xIRIX
then
        DISTNAME=irix
elif test $HAVE_UNAME=yes -a x`uname -s` = xBSD/OS
then
        DISTNAME=bsdi
elif test -f /etc/SuSE-release
then
        DISTNAME=suse
elif test -d /etc/SuSEconfig
then
        DISTNAME=suse5
elif test -f /etc/mandrake-release
then
        DISTNAME=mandrake
elif test -f /etc/fedora-release
then
        DISTNAME=fedora
elif test -f /etc/whitebox-release
then
       DISTNAME=redhat
elif test -f /etc/redhat-release
then
       if grep -q CentOS /etc/redhat-release
       then
           DISTNAME=centos
       else
           DISTNAME=redhat
       fi
elif test -f /etc/gentoo-release
then
        DISTNAME=gentoo
elif test -f /etc/debian_version
then
        DISTNAME=debian
elif test -f /etc/slackware-version
then
        DISTNAME=slackware
elif test $HAVE_UNAME=yes -a x`uname -s` = xDarwin
then
    DISTNAME=darwin
elif test -f /etc/engarde-version
then
        DISTNAME=engarde
elif test "$CYGWIN" = yes
then
        DISTNAME=cygwin
else
        DISTNAME=unknown
fi

case "$DISTNAME" in
aix)
        DISTVER=`uname -r`
  ;;
alpha)
        DISTVER=`uname -r`
  ;;
bsdi)
        DISTVER=`uname -a |awk '{print $3}'`
  ;;
cygwin)
        DISTVER=`uname -a |awk '{print $3}'`
  ;;
darwin)
        DISTVER=`uname -r`
  ;;
debian)
        if `grep -q ubuntu /etc/apt/sources.list`; then
           DISTVER="Ubuntu"
        else
           DISTVER=`cat /etc/debian_version`
        fi
        if test -f /etc/lsb-release ; then
           . /etc/lsb-release
           if test "x$DISTRIB_ID" != "x" ; then
              DISTNAME=$DISTRIB_ID
           fi
           if test "x$DISTRIB_RELEASE" != "x" ; then
              DISTVER=$DISTRIB_RELEASE
           fi
        fi
  ;;
freebsd)
        DISTVER=`uname -a |awk '{print $3}'`
  ;;
hpux)
        DISTVER=`uname -r`
  ;;
irix)
        DISTVER=`uname -r`
  ;;
netbsd)
        DISTVER=`uname -a |awk '{print $3}'`
  ;;
openbsd)
        DISTVER=`uname -a |awk '{print $3}'`
  ;;
redhat)
        if test -f /etc/whitebox-release ; then
           f=/etc/whitebox-release
        else
           f=/etc/redhat-release
        fi
        if test `cat $f | grep release |\
                   cut -f 3 -d ' '`x = "Enterprise"x ; then
           DISTVER="RHEL "`cat $f | grep release | cut -f 6 -d ' '`
        else
            DISTVER=`cat /etc/redhat-release | grep release |\
                     cut -f 5 -d ' '`
        fi
  ;;
centos)
  DISTVER=`cat /etc/redhat-release | grep release |\
           cut -f 3 -d ' '`
  ;;
fedora)
        if test `cat /etc/fedora-release | grep release | cut -f 2 -d ' '`x = "Core"x ; then
            DISTVER=`cat /etc/fedora-release | grep release |cut -f 4 -d ' '`
        else
            DISTVER=`cat /etc/fedora-release | grep release |cut -f 3 -d ' '`
        fi
  ;;
mandrake)
        DISTVER=`cat /etc/mandrake-release | grep release |\
           cut -f 5 -d ' '`
  ;;
gentoo)
        DISTVER=`awk '/version / {print $5}' < /etc/gentoo-release`
  ;;
slackware)
        DISTVER=`cat /etc/slackware-version`
  ;;
solaris)
        DISTVER=`uname -r`
  ;;
suse)
        DISTVER=`cat /etc/SuSE-release |grep VERSION|\
            cut -f 3 -d ' '`
  ;;
suse5)
        DISTNAME=suse
        DISTVER=5.x
  ;;
unknown)
        DISTVER=unknown
  ;;
*)
  echo " === Something went wrong. Unknown DISTNAME $DISTNAME ==="
  ;;
esac


echo "${DISTNAME}-${DISTVER}" | sed -e 's,/,-,g'
